<?php
namespace src\lib;

use src\Curl;

/**
 * 苏宁图床(失效)
 * @package src\lib
 * @url https://www.suning.com/
 */

class Suning
{   
    public function upload($path)
    {
        $data = [
            'Filedata'       => Curl::getCurlFile($path),
            'omsOrderItemId' => 1,
            'custNum'        => 1,
            'deviceType'     => 1,
        ];
        $result = Curl::post('http://review.suning.com/imageload/uploadImg.do', $data, [
            CURLOPT_HTTPHEADER => [
                'Referer: http://review.suning.com/my_cmmdty_review.do',
            ],
        ]);

        $result = json_decode($result, true);
        if ($result['errorcode'] != '1') {
            return false;
        }

        return "https:{$result['src']}.jpg";
    }

}